package com.atguigu.flink.charkoer13;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

public class FlinkSqlFile {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);

        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);

        tEnv.executeSql("create table sensor(" +
                " id string,ts bigint,vc int) " +
                " with(" +
                " 'connector' = 'filesystem'," +
                " 'path' = 'input/sensor.txt'," +
                " 'format' = 'csv'" +
                ")");

        Table table = tEnv.sqlQuery("select * from sensor where id = 'sensor_1'");

        tEnv.executeSql("create table s_out( id string,ts bigint,vc int)with( 'connector' = 'filesystem','path' = 'input/b.txt','format' = 'csv')");

        table.executeInsert("s_out");


    }
}
